package com.xd.springboot.controller;

import com.xd.springboot.entity.JsonResult;
import com.xd.springboot.entity.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/json")
public class JsonController {
    @RequestMapping("/user")
    public JsonResult<User> getUser()
    {
        User user=new User((long) 1.0,"测试","123456");
        return new JsonResult<>(user);
    }

    @RequestMapping("/list")
    public List<User> getUserList()
    {
        List<User> userList = new ArrayList<>();
        User user1 = new User((long) 2.0,"测试","123456");
        User user2 = new User((long) 3.0,"测试","123456");
        userList.add(user1);
        userList.add(user2);
        return userList;
    }

    @RequestMapping("/map")
    public Map<String, Object> getMap()
    {
        Map<String,Object> map=new HashMap<>(3);
        User user1 = new User((long) 4.0,"测试","123456");
        map.put("用户信息",user1);
        map.put("博客地址","广东深甚至是");
        map.put("空测试",null);
        return  map;
    }

}
